﻿using System.Windows;
using System.Windows.Controls;
using SoftSource.Common;
using SoftSource.MVVMC;
using SoftSource.Timecard.ViewModelInterfaces;

namespace SoftSource.Timecard.Views
{
    public sealed partial class SummaryView : UserControl, IView<ISummaryViewModelConsume>
    {
        public SummaryView()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(SummaryView_Loaded);
        }

        #region Events

        void SummaryView_Loaded(object sender, RoutedEventArgs e)
        {
            this.InitializePriorEntriesView();
            this.InitializeUtilizationSummaryView();
            this.InitializeCreateEntriesFlaggedForAdminView();
        }

        #endregion Events

        #region Methods

        private void InitializePriorEntriesView()
        {
            this.EntriesPriorToProjectBillingDateContent.Content = this.ViewModel.CreatePriorEntriesView.TryInvoke();
        }

        private void InitializeUtilizationSummaryView()
        {
            this.UtilizationContent.Content = this.ViewModel.CreateUtilizationSummaryView.TryInvoke();
        }

        private void InitializeCreateEntriesFlaggedForAdminView()
        {
            this.EntriesFlaggedForAdminContent.Content = this.ViewModel.CreateEntriesFlaggedForAdminView.TryInvoke();
        }

        #endregion Methods

        #region IView<ISummaryViewModelConsume> Members

        public ISummaryViewModelConsume ViewModel
        {
            get { return this.DataContext as ISummaryViewModelConsume; }
            set { this.DataContext = value; }
        }

        #endregion
    }
}
